import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class project2 {
    public static List<People> peopleList = new ArrayList<>();
    public static void main(String[] args) {

        Random random = new Random();
        for (int i = 1; i <= 100 ; i++) {
            int code = random.nextInt(200)+1;
            if (runnable(code)){
                People people = new People(code,i);
                peopleList.add(people);
            }else {
                i--;
            }
        }
        System.out.println(peopleList);

        while (peopleList.size() > 1){
            List<People> tempPeople = new ArrayList<>();
            for (int i = 1; i < peopleList.size(); i += 2) {
                tempPeople.add(peopleList.get(i));
            }
            peopleList = tempPeople;
        }
        System.out.println(peopleList);
    }
    public static boolean runnable(int code){
        for (int i = 0; i < peopleList.size(); i++) {
            if (peopleList.get(i).getCode() == code){
                return false;
            }
        }
        return true;
    }
}
